package com.xjy.web.controller.controller;

import java.math.BigDecimal;
import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import javax.validation.constraints.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.xjy.common.annotation.RepeatSubmit;
import com.xjy.common.annotation.Log;
import com.xjy.common.core.controller.BaseController;
import com.xjy.common.core.domain.AjaxResult;
import com.xjy.common.enums.BusinessType;
import com.xjy.system.domain.vo.ReportLoanVo;
import com.xjy.system.domain.bo.ReportLoanQueryBo;
import com.xjy.system.service.IReportLoanService;
import com.xjy.common.utils.poi.ExcelUtil;
import com.xjy.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * ReportLoanController
 *
 * @author zc
 * @date 2022-02-28
 */
@Api(value = "个人借款汇总控制器", tags = {"个人借款汇总管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/system/report_loan")
public class ReportLoanController extends BaseController {

	private final IReportLoanService iReportLoanService;

	/**
	 * 查询个人借款汇总列表
	 */
	@ApiOperation("查询个人借款汇总列表")
	@PreAuthorize("@ss.hasPermi('system:report_loan:list')")
	@GetMapping("/list")
	public TableDataInfo<ReportLoanVo> list(@Validated ReportLoanQueryBo bo) {
		return iReportLoanService.queryPageList(bo);
	}

	/**
	 * 导出个人借款汇总列表
	 */
	@ApiOperation("导出个人借款汇总列表")
	@PreAuthorize("@ss.hasPermi('system:report_loan:export')")
	@Log(title = "个人借款汇总", businessType = BusinessType.EXPORT)
	@GetMapping("/export")
	public AjaxResult<ReportLoanVo> export(@Validated ReportLoanQueryBo bo) {
		List<ReportLoanVo> list = iReportLoanService.queryList(bo);
		ExcelUtil<ReportLoanVo> util = new ExcelUtil<ReportLoanVo>(ReportLoanVo.class);
		return util.exportExcel(list, "个人借款汇总");
	}

	/**
	 * 获取个人借款汇总详细信息
	 */
	@ApiOperation("获取个人借款汇总详细信息")
	@PreAuthorize("@ss.hasPermi('system:report_loan:query')")
	@GetMapping("/{projId}")
	public AjaxResult<ReportLoanVo> getInfo(@NotNull(message = "主键不能为空")
											@PathVariable("projId") Long projId) {
		return AjaxResult.success(iReportLoanService.queryById(projId));
	}


}
